/**
 * 过滤装置
 */
Shelf = Widget.extend({
	ctor:function(parent){
		this._super();
		parent.addChild(this, 9,TAG_SHELF);
		this.initShelf();
	},
	initShelf:function(){
		var filter_shelf = new Button(this, 10, TAG_FILTER, "#ironShelf1.png", this.callback);
		filter_shelf.setPosition(cc.p(160,270));
		
		this.callNext = cc.callFunc(function(){
			gg.flow.next();
		}, this);
		this.callNext.retain();
	},
	callback:function(p){
		var action=gg.flow.flow.action;
		switch(p.getTag()){
		case TAG_FILTER:
			if(action==ACTION_DO1){			
				p.setSpriteFrame("ironShelf2.png");
				var filter_paper = new Button(this, 5, TAG_FILTERPAPER1, "#filter_paper1.png", this.callback);
				filter_paper.setPosition(cc.p(140,270));
				var move1=cc.moveTo(0.6, cc.p(140,350));
				var move2=cc.moveTo(0.6, cc.p(360,350));
				var seq=cc.sequence(move1,move2,cc.callFunc(function() {
					filter_paper.setSpriteFrame("filter_paper2.png");
					var show=new ShowTip("2NaHCO₃  ≜  Na₂CO₃ + H₂O + CO₂↑ \n" +
							"生成碳酸钠，俗称纯碱，\n" +
							"生成气体为二氧化碳，可循环利用，重新注入反应容器" ,cc.p(720,230));
				}, this),cc.delayTime(1),cc.callFunc(function() {
					gg.flow.next();
				}, this));
				filter_paper.runAction(seq);		
			}else if(action==ACTION_DO2){
				p.setSpriteFrame("ironShelf2.png");
				var filter_paper = new Button(this, 5, TAG_FILTERPAPER2, "#filter_paper1.png", this.callback);
				filter_paper.setPosition(cc.p(140,270));
				var move1=cc.moveTo(0.6, cc.p(140,350));
				var move2=cc.moveTo(0.6, cc.p(490,350));
				var seq=cc.sequence(move1,move2,cc.callFunc(function() {
					filter_paper.setSpriteFrame("filter_paper2.png");
					var show=new ShowTip("反应析出的NH₄Cl结晶在洗涤、\n" +
							"干燥后，工业上可用作化肥",cc.p(700,230));
				}, this),cc.delayTime(1),cc.callFunc(function() {
					gg.flow.next();
				}, this));
				filter_paper.runAction(seq);				
			}
			break;
		}
	},
	onExit:function(){
		this._super();
		this.callNext.release();
	}
});